unit ControleMesaDM;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, db, FileUtil, LResources, Forms, Controls, Graphics,
  Dialogs, ZDataset, MainDM;

type

  { TControleMesaData }

  TControleMesaData = class(TMainDataModule)
    ControleMesaDatasource: TDatasource;
    ControleMesaZQuery: TZQuery;
    ControleMesaZQuerydesc_mesa: TStringField;
    ControleMesaZQueryid_mesa: TLargeintField;
    ControleMesaZQuerystatus: TStringField;
    AuxiliarZQuery: TZQuery;
    procedure DataModuleCreate(Sender: TObject);
     /// Abre o DataSet
    procedure OpenDataSet(); override;
    /// Fecha o DataSet
    procedure CloseDataSet(); override;
    /// Realiza busca
    /// @param(Condicoes são as condições para a busca)
    /// @param(Tabela é a tabela no banco de dados)
    procedure Search(Condicoes: TQueryConditions; Tabela: string); override;
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  ControleMesaData: TControleMesaData;

implementation

{ TControleMesaData }

procedure TControleMesaData.DataModuleCreate(Sender: TObject);
begin
   MainDataSet := ControleMesaZQuery;
end;

procedure TControleMesaData.OpenDataSet();
begin
    ConnectionData.EmptyQuery(ControleMesaZQuery, 'mesa');
end;

procedure TControleMesaData.CloseDataSet();
begin
    ControleMesaZQuery.Close();
end;

procedure TControleMesaData.Search(Condicoes: TQueryConditions; Tabela: string);
begin
     ConnectionData.OpenQueryConditions(ControleMesaZQuery, Tabela, Condicoes);
end;

initialization
  {$I controlemesadm.lrs}

end.

